#!/bin/sh
JAVA_OPTS=""
JAVA_OPTS=$JAVA_OPTS" -Dcom.sun.management.jmxremote"
JAVA_OPTS=$JAVA_OPTS" -Dcom.sun.management.jmxremote.port=9999"
JAVA_OPTS=$JAVA_OPTS" -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS=$JAVA_OPTS" -Dcom.sun.management.jmxremote.ssl=false"
exec java $JAVA_OPTS -verbosegc -jar jajmx.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

if (args.size == 0) {
  println("Usage   : jmxgrep host port")
  println("  no args given so now let's connecting to myself, and force a gc...") 
}
val host  = if (args.size>1) args(0) else "localhost"
val port  = if (args.size>2) args(1).toInt else 9999

jajmx.JMX.once(host, port) { _.gcforce }

